package com.heima.article.service.impl;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.article.mapper.ApArticleConfigMapper;
import com.heima.article.service.ApArticleConfigservice;
import com.heima.model.article.pojos.ApArticleConfig;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ApArticleConfigserviceImpl extends ServiceImpl<ApArticleConfigMapper, ApArticleConfig> implements ApArticleConfigservice {
    /**
     * 修改文章上下架
     *
     * @param articleId
     * @param enable    0 下架  1上架
     *                  is_down  0 上架  1 下架
     */
    @Override
    public void downOrUpArtlicle(Long articleId, Integer enable) {
        //0 下架 1 上架
        if (articleId != null && enable != null) {
            /// 先查三剑客详情
            ApArticleConfig articleConfig = getOne(Wrappers.<ApArticleConfig>lambdaQuery().eq(ApArticleConfig::getArticleId, articleId));
            if (articleConfig != null) {
                articleConfig.setIsDown(enable == 1?false:true);
                updateById(articleConfig);
            }
        }
    }
}
